home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mc51bugs / q31751 < prev    next >
Text File  |  1988-07-20  |  1KB  |  61 lines

  1. Q31751 Incorrect Code with /Oal and Do-While Loop
  2. C Compiler
  3. 5.10
  4. MS-DOS
  5.  
  6. Summary:
  7.    The code generated for the do-while loop in the example below
  8. is incorrect when it is compiled with /Oal (or /Ox). The generated
  9. code will execute the loop 65535 times, causing memory to be
  10. overwritten and potentially hanging the machine. The do-while loop
  11. should execute only once.
  12.    Microsoft has confirmed this to be a problem in Version 5.10 of the
  13. C compiler.
  14.    To work around the problem, make an assignment to a dummy variable
  15. inside the do-while loop. For example, changing the following
  16. statement:
  17.  
  18.    ++argm;
  19.  
  20. to the following will work around the problem:
  21.  
  22.    temp = ++argm;
  23.  
  24.    Microsoft is researching this problem and will post new information
  25. as it becomes available.
  26.  
  27. More Information:
  28.    The following code demonstrates the problem:
  29.  
  30. char *argj[100];
  31. void main()
  32. {
  33.   int     argn;
  34.   int     argm;
  35.   int     argi;
  36.   argi = foo(); /* initialize argi to 2 */
  37.   argn = 1;
  38.   while (argn < argi)
  39.   {
  40.     argm  = argn;
  41.     argi--;
  42.  
  43.     do
  44.     {
  45.       argj[argm] = argj[argm+1];
  46.       ++argm;
  47.     }
  48.     while (argm < argi);
  49.  
  50.     argn++;
  51.   }
  52. }
  53. foo()
  54. { return 2;
  55. }
  56.  
  57.  
  58.  
  59. Keywords:  buglist5.10 TAR78086
  60. Updated  88/07/21 03:19
  61.